/*
** 2602.c
** 
** Made by (seakage2h)
** Login   <seakage2h@seakage2h-ubuntu>
** 
** Started on  Thu Oct 16 14:57:03 2008 seakage2h
** Last update Sun May 12 01:17:25 2002 Speed Blue
*/

/* #include "2602.h" */
#include <stdio.h>

int main()
{
     int bits, i;
     char addend1, addend2;
     char tmp, tmp2;
     int nines;
     
     scanf("%d", &bits);
     scanf("\n%c %c\n", &addend1, &addend2);
     tmp = addend1 - '0' + addend2 - '0';
     nines = 0;
     
     for(i = 2; i <= bits; i++){
	  scanf("%c %c\n", &addend1, &addend2);
	  tmp2 = addend1 - '0' + addend2 - '0';
	  if (tmp2 >= 10){
	       putchar(tmp + '1');
	       while(nines > 0){
		    putchar('0');
		    nines--;
	       } /* nines becomes '0' */
	       tmp = tmp2 - 10;
	  }
	  else if (tmp2 == 9)
	       nines++;
	  else{
	       putchar(tmp + '0');
	       while(nines > 0){
		    putchar('9');
		    nines--;
	       } /* nines becomes '0' */
	       tmp = tmp2;
	  }
     }
     putchar(tmp + '0');
     while(nines > 0){
	  putchar('9');
	  nines--;
     } /* nines becomes '0' */
     
     
     putchar('\n');

     return 0;
}

